package leecode

import (
	"strconv"
	"strings"
)

func complexNumberMultiply(num1 string, num2 string) string {
	//找到字符串中加号的位置
	index1 := strings.Index(num1, "+")
	index2 := strings.Index(num2, "+")
	var aStr, bStr, cStr, dStr string
	aStr = num1[0:index1]
	bStr = num1[index1+1 : len(num1)-1]
	cStr = num2[0:index2]
	dStr = num2[index2+1 : len(num2)-1]
	a, _ := strconv.Atoi(aStr)
	b, _ := strconv.Atoi(bStr)
	c, _ := strconv.Atoi(cStr)
	d, _ := strconv.Atoi(dStr)
	i := a*c - b*d
	j := b*c + a*d
	result := strconv.Itoa(i) + "+" + strconv.Itoa(j) + "i"
	return result
}
